TEB Computer Kids Academy

        

Programming with LOGO


Logo is an education-oriented
functional programming language designed
in 1967 by Daniel G. Bobrow,
Wally Feurze, Seymour Papert and Cynthia Solomon.
Logo is easy to learn and was
most widespread in the 1980s,
at the time of home computers.
It is used for teaching students
and children how to program

LOGO programming language is a set of commands
to be performed by an object, usually a turtle.
LOGO is a great language for kids,
as well as teachers, parents,
and anyone interested in programming.

Why should we learn the Logo language?

Because it is fun, lots of fun.
Enhances the logical sense of the children.
Develops programming skills.
help kids in Critical thinking and problem solving.
kids use computers to engage the world as designers and builders.
Enhence kids Communication as well as Collaboration,
Kids learn Creativity and innovation

The commands and their
abbreviations are given below -







forward 60 or fd 60 means go forward 60 steps
-right 90 or rt 90 means right turn 90 degrees
-left 90 or lt 90 means left turn 90 degrees
-back 60 or bk 60 means go back 60 steps
-clearscreen or cs means erase all drawings
Logo has a number of other drawing commands,
some of which are given below.

pu - penup
pd - pendown
ht - hideturtle
dt - showturtle
setpensize


penup or pu means pick pen up,
so you can move turtle without leaving tracks.
pendown or pd means pick pen down,
so you can move the turtle and leave tracks.
hideturtle or ht means hide the turtle,
so you can admire your drawing.
showturtle or st means show the turtle,
so you can continue your drawing.

setpensize means it can make the pen larger,
easier to see. Default pen size is -[1 1].

LOGO "HELLO WORLD"!



Write LOGO Program codes that can display: Hello world!

Print (Hello World!)


LOGO Variables

A variable is the name of a memory
location which can contain a value
variable name can contain alphabets
(case insensitive), digits and underscore.


In the above example,
we have defined two variables
first_name, 100_last_name_200

and initialized them with values
Amal and Das using the following statements -

make "first_name "Amal
make "100_last_name_200 "Das


example shows how to define numeric variables -




Logo - Arithmetic Operations

Logo provides the usual arithmetic operations of
addition, subtraction, multiplication and division,
shown symbols +, -, *, /





more useful commands are-

sqrt - It takes one non-negative argument
and returns its square root.
power - It takes two arguments,
call them 'a' and -b', and generates a to the b power.
ln - It takes one argument and returns its natural logarithm.

exp - It takes one argument and
computes e to that power, e is the natural number 2.718281828.
log10 - It takes the logarithm to base 10 of its one argument







Logo - Repetition

We sometimes repeat a sequence of commands
Computer programs often perform repetitive tasks

assume we want to draw a square
with sides of length 100,
you can do this with the
following program:

fd 100
rt 90
fd 100
rt 90
fd 100
rt 90
fd 100
rt 90


Note that the two commands -
fd 100 and rt 90 are repeated four times

We can do exactly this, using the following command -













Sometimes, we might have to repeat within repeat.
This is called nesting.
Let us look at some examples on this.













Logo - Randomization

Logo provides a random
procedure to generate a random number.
It produces an integer
value chosen uniformly at random,
for example,
if you want a random angle between 0 and 359 degrees,
you can use the command random 360 to produce it

example -







You have issued the command -

print random 360 several times in the
above command window and if you notice,
each time it generates a random output.













Logo - Color

Computer screens work with
red, green and blue components of light,
so they are sometimes called RGB screens.

On Logo's Set menu,
we set the color of three screen elements -






you can also mix-up colours
if you mix red and green paint,
you get a muddy color.

The following commands
will give you a big fat red pen -
setpensize [5 5]
setpencolor [255 0 0]

output of the above code.






You can make a colored
square using the following steps -

Step 1 -
Draw the square with side
length 40 using the following command.
repeat 4 [fd 40 rt 90]

Step 2 -
Pen up using the following command.
pu

Step 3 -
Go to a point inside the square.
For example, place the turtle at coordinate
(20, 20) using the following command.
setxy 20 20

Step 4 -
Fill the square with the set floodcolor.
For example, to set the floodcolor
to blue use the following command.
setfloodcolor [0 0 255]

The following table lists a few
more Color and pen related commands.













Let's start coding
click on LOGO INTERPRETER below
and start your own coding execises
you can also RUN the codes your have written to see the result
follow both the above and beloiw examples and start coding
change codes and RUN the program to see the outcome

KEEP CODING !!!



click here and start CODING









Editorial APPs...click 'N' view